﻿Public Class TMyEvent
    Inherits TCustomMyObject
    Private _Events As TMyEvents

    Friend _EventCatalog As String
    Friend _EventSchema As String
    Friend _EventName As String
    Friend _Definer As String
    Friend _TimeZone As String
    Friend _EventBody As String
    Friend _EventDefinition As String
    Friend _EventType As String
    Friend _ExecuteAt As DateTime
    Friend _IntervalValue As String
    Friend _IntervalField As String
    Friend _SqlMode As String
    Friend _Starts As DateTime
    Friend _Ends As DateTime
    Friend _Status As String
    Friend _OnCompletion As String
    Friend _Created As DateTime
    Friend _LastAltered As DateTime
    Friend _LastExecuted As DateTime
    Friend _EventComment As String
    Friend _Originator As Integer
    Friend _CharacterSetClient As String
    Friend _CollationConnection As String
    Friend _DatabaseCollation As String
    Public ReadOnly Property EventCatalog() As String
        Get
            Return _EventCatalog
        End Get
    End Property
    Public ReadOnly Property EventSchema() As String
        Get
            Return _EventSchema
        End Get
    End Property
    Public ReadOnly Property EventName() As String
        Get
            Return _EventName
        End Get
    End Property
    Public ReadOnly Property Definer() As String
        Get
            Return _Definer
        End Get
    End Property
    Public ReadOnly Property TimeZone() As String
        Get
            Return _TimeZone
        End Get
    End Property
    Public ReadOnly Property EventBody() As String
        Get
            Return _EventBody
        End Get
    End Property
    Public ReadOnly Property EventDefinition() As String
        Get
            Return _EventDefinition
        End Get
    End Property
    Public ReadOnly Property EventType() As String
        Get
            Return _EventType
        End Get
    End Property
    Public ReadOnly Property ExecuteAt() As DateTime
        Get
            Return _ExecuteAt
        End Get
    End Property
    Public ReadOnly Property IntervalValue() As String
        Get
            Return _IntervalValue
        End Get
    End Property
    Public ReadOnly Property IntervalField() As String
        Get
            Return _IntervalField
        End Get
    End Property
    Public ReadOnly Property SqlMode() As String
        Get
            Return _SqlMode
        End Get
    End Property
    Public ReadOnly Property Starts() As DateTime
        Get
            Return _Starts
        End Get
    End Property
    Public ReadOnly Property Ends() As DateTime
        Get
            Return _Ends
        End Get
    End Property
    Public ReadOnly Property Status() As String
        Get
            Return _Status
        End Get
    End Property
    Public ReadOnly Property OnCompletion() As String
        Get
            Return _OnCompletion
        End Get
    End Property
    Public ReadOnly Property Created() As DateTime
        Get
            Return _Created
        End Get
    End Property
    Public ReadOnly Property LastAltered() As DateTime
        Get
            Return _LastAltered
        End Get
    End Property
    Public ReadOnly Property LastExecuted() As DateTime
        Get
            Return _LastExecuted
        End Get
    End Property
    Public ReadOnly Property EventComment() As String
        Get
            Return _EventComment
        End Get
    End Property
    Public ReadOnly Property Originator() As Integer
        Get
            Return _Originator
        End Get
    End Property
    Public ReadOnly Property CharacterSetClient() As String
        Get
            Return _CharacterSetClient
        End Get
    End Property
    Public ReadOnly Property CollationConnection() As String
        Get
            Return _CollationConnection
        End Get
    End Property
    Public ReadOnly Property DatabaseCollation() As String
        Get
            Return _DatabaseCollation
        End Get
    End Property

    Friend Sub New(ByVal AOwner As TCustomMyObjects, ByVal AObjectName As String)
        MyBase.New(AOwner, AObjectName)
        _Events = AOwner
    End Sub
    Friend Sub InitSource()
        MyQuery.Clear()
        MyQuery.SQL.Append("show create event `").Append(Me.EventSchema).Append("`.`").Append(Me.EventName).Append("`")
        MyQuery.Execute()
        _Source = MyQuery.FieldAsString("Create Event")
        MyQuery.Close()
    End Sub

    Public Overrides ReadOnly Property Source() As String
        Get
            InitSource()
            Return _Source
        End Get
    End Property
End Class
